from rest_framework.generics import ListAPIView
from rest_framework.viewsets import ModelViewSet
from goods.models import GoodsChannel, GoodsChannelGroup, GoodsCategory
from meiduo_admin.channel.channel_serializers import ChannelSerializer, ChannelGroupSerializer, CategoriesSerializer
from meiduo_admin.user.my_pagination import MyNumberPagination


# 获取频道
class ChannelsViewSet(ModelViewSet):
    pagination_class = MyNumberPagination
    queryset = GoodsChannel.objects.all()
    serializer_class = ChannelSerializer


# 获取频道组
class ChannelGroupViewSet(ListAPIView):
    pagination_class = None
    queryset = GoodsChannelGroup.objects.all()
    serializer_class = ChannelGroupSerializer


# 新增频道获取一级分类  感觉有点怪
class CategoriesViewSet(ListAPIView):
    pagination_class = None
    queryset = GoodsCategory.objects.filter(parent=None).all()
    serializer_class = CategoriesSerializer

    # def get_queryset(self):
    #     obj = self.get_object()
    #     return None
